package com.ssy.lingxi.system.dao;

import com.ssy.lingxi.system.dto.response.MemberEquitiesUseResponse;
import com.ssy.lingxi.system.entity.MemberEquitiesUse;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface MemberEquitiesUseRepository extends JpaRepository<MemberEquitiesUse, Long>,JpaSpecificationExecutor<MemberEquitiesUse> {
    /**
    * 查询权益设置列表
    * @author wrc
    * @date 2020/5/18
    */
    @Query("select new com.ssy.lingxi.system.dto.response.MemberEquitiesUseResponse( meu.id,meu.explain,meu.name,meu.memberEquitiesId,meu.parameterManner,meu.state,me.equitiesName) " +
                    "from MemberEquitiesUse meu,MemberEquities me where meu.memberEquitiesId =me.id")
    List<MemberEquitiesUseResponse> memberEquitiesUseList(Pageable pageable);


    /**
     * 查询权益设置总记录数
     * @author wrc
     * @date 2020/5/18
     */
    @Query(nativeQuery = true,
            value = "select count(1) from cf_member_equities_use meu left join  cf_member_equities me on meu.member_equities_id =me.id")
    Long memberEquitiesUseCount();

}
